package com.sh.代理模式.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

class MusicPlayerInvocationHandler implements InvocationHandler {
    private Object target;

    public MusicPlayerInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("Before playing music.");
        Object result = method.invoke(target, args);
        System.out.println("After playing music.");
//        return result;
        return null;
    }
}